// 判断开始游戏结束游戏跳转函数
import {mapGetters} from 'vuex'
export default {
	computed: {
		...mapGetters(['loginForm','hrefFlag']),
		userType(){
			return this.loginForm.userType;
		}
	},
	onShow(){
		if(this.userType!=='issue'){
			uni.$on('completeCar',res=>{
				if(res.customEvent==='gather_game_tips') return false;
				// const flag = res.userSmallDtos.some(val=>val.uid==this.loginForm.uid);
				const userSmallIds = res.userSmallIds.split(',') || [];
				const flag = userSmallIds.some(val=>val==this.loginForm.uid);
				if(flag){  //如果存在当前车上才跳转到倒计时列表
					this.$u.toast('测本已完成，快去提交意向吧！');
					//this.$store.dispatch('setHrefFlag',false)
					const getHrefFlag = uni.getStorageSync('setHrefFlag');
					if(getHrefFlag) return false;
					uni.setStorageSync('setHrefFlag',true);
					this.goLoading(res.driveCarId)
					//this.$store.dispatch('setHrefFlag',true)
					//console.log(1111111666666)
				}
			})
			uni.$on('startCar',res=>{
				if(res.customEvent==='gather_game_tips') return false;
				if(!this.hrefFlag) return false;
				//this.$store.dispatch('setHrefFlag',false)
				// const flag = res.userSmallDtos.some(val=>val.uid==this.loginForm.uid);
				const userSmallIds = res.userSmallIds.split(',') || [];
				const flag = userSmallIds.some(val=>val==this.loginForm.uid);
				if(flag){  //如果存在当前车上才跳转到倒计时列表
					const getHrefFlag = uni.getStorageSync('setHrefFlag');
					if(getHrefFlag) return false;
					uni.setStorageSync('setHrefFlag',true);
					this.goLoading(res.driveCarId)
				}
			})
		}
	},
	onUnload(){
		uni.$off('completeCar')
		uni.$off('startCar')
	},
	methods:{
		goLoading(driveCarId){
			this.$u.route({
				url:'/pagesA/carTime/carTime',
				params:{
					id:driveCarId
				}
			})
		}
	}
}
